import {
	defineConfig
} from 'vite';
import uniTailwind from '@uni-helper/vite-plugin-uni-tailwind';
import tailwindcss from 'tailwindcss';
import uni from '@dcloudio/vite-plugin-uni';

import path from "path";
// 注意： 打包成 h5 和 app 都不需要开启插件配置
const isH5 = process.env.UNI_PLATFORM === "h5";
const isApp = process.env.UNI_PLATFORM === "app";
const WeappTailwindcssDisabled = isH5 || isApp;

const resolve = (p) => {
	return path.resolve(__dirname, p);
};
import {
	UnifiedViteWeappTailwindcssPlugin as uvwt
} from "weapp-tailwindcss/vite";

export default defineConfig({
	css: {
		postcss: {
			plugins: [
				require("tailwindcss")({
					// 注意此处，手动传入你 `tailwind.config.js` 的绝对路径
					config: resolve("./tailwind.config.js"),
				}),
				require("autoprefixer")(),
			],
		},
	},
	plugins: [uni(), uvwt({
		// 由于 hbuilderx 会改变 process.cwd 所以这里必须传入当前目录的绝对路径
		// 上面参考视频没有这一个,但是不加的话会报错
		tailwindcssBasedir: __dirname
	})],
});